package com.ag.lwc.dao;

import java.sql.SQLException;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.ag.bean.TbEventStatus;
import com.ag.common.IDUtil;
import com.ag.dao.TbEventStatusDAO;

public class MyTbEventStatusDAO extends TbEventStatusDAO
{
	public List findAll()
	{
		return getHibernateTemplate().executeFind(new HibernateCallback(){

						@Override
						public Object doInHibernate(Session session) throws HibernateException, SQLException 
							{
							   	Criteria crit = session.createCriteria(TbEventStatus.class);
							   	crit.add(Restrictions.or(Restrictions.isNull(A),Restrictions.not(Restrictions.eq(A,IDUtil.DELETE))));
								crit.addOrder(Order.asc("tbesId"));
							   	return crit.list();
							}});
		
	}
	public void delete(final String id)
	{
		this.getHibernateTemplate().execute(new HibernateCallback(){

			@Override
			public Object doInHibernate(Session session)
					throws HibernateException, SQLException
			{
				TbEventStatus status = (TbEventStatus) session.get(TbEventStatus.class, id);
				status.setA(IDUtil.DELETE);
				
				return null;
			}});
	}

}
